<script type="text/javascript">
	function doSearchRoomConfig(value) {
		
	}
	
	//表格查询  
	function reloadRoomConfig() {
		var params = roomConfig_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		roomConfig_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		roomConfig_list.datagrid('unselectAll');
		roomConfig_list.datagrid('uncheckAll');
		
		var params = $('#deviceLink_selectlist').datagrid('options').queryParams;
		params['roomType'] = '';
		deviceLink_selectlist.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		deviceLink_selectlist.datagrid('unselectAll');
		deviceLink_selectlist.datagrid('uncheckAll');
	}


	function addRoomConfig() {
		createFromWindowOptions({
			title:"新增信息",
			maximizable:true,
			href: "roomConfig.do?editRoomConfig",
			callback:function(data) {
				saveRoomConfigInfo();
			},
			enableSaveButton:true,
			width:1000,
			height:600
		});
	}
	
	function deleteRoomConfig() {
		var rows = roomConfig_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('roomConfig.do?deleteRoomConfigItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadRoomConfig();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editRoomConfig() {
		var rows = roomConfig_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindowOptions({
				title:"编辑信息",
				maximizable:true,
				href: "roomConfig.do?editRoomConfig&roomConfigId=" + rows[0].id,
				callback:function(data) {
					saveRoomConfigInfo();
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookRoomConfig(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = roomConfig_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "roomConfig.do?editRoomConfig&roomConfigId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditRoomConfig(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = roomConfig_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindowOptions({
				title:"编辑信息",
				maximizable:true,
				href: "roomConfig.do?editRoomConfig&roomConfigId=" + id,
				callback:function(data) {
					saveRoomConfigInfo();
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsDeleteRoomConfig(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('roomConfig.do?deleteRoomConfigItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadRoomConfig(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function onClickDeviceLink(rowIndex, rowData) {
		printLog(rowIndex);
		//先取得 datagrid 的查询参数  
		var params = $('#deviceLink_selectlist').datagrid('options').queryParams;
		params['roomType'] = rowData.roomType;
		//设置好查询参数 reload 一下就可以了 
		$('#deviceLink_selectlist').datagrid('reload');  
	}
</script>

<#assign operations = "[\{shiro:'hotel:roomConfig:refresh',onClick:'operationsLookRoomConfig',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'hotel:roomConfig:delete',onClick:'operationsDeleteRoomConfig',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region: 'west',border:false, split: true," style="width: 700px;">
		<div div class="easyui-layout" data-options="fit:true">
			<div data-options="region: 'north', title: '客房配置定义',border:false, split: true," style="height: 200px;">
				<@eu.datagrid id="roomConfig_list" toolbar="#roomConfiglist_search" idField="id" operations="${operations!}"
					 url="roomConfig.do?loadList" rownumbers="true" onClickRow="onClickDeviceLink(rowIndex, rowData)"
					 item="com.xdtech.hotel.vo.RoomConfigItem" pagination="false"/>
				
				<div id="roomConfiglist_search">
					<div id="roomConfig_toolbar" style="height: auto">
						
						<@eu.linkbutton showName="新增" shiro="hotel:roomConfig:add" iconCls="icon-add" onclick="addRoomConfig()"/>
						<@eu.linkbutton showName="删除" shiro="hotel:roomConfig:delete" iconCls="icon-remove" onclick="deleteRoomConfig()"/>
						<@eu.linkbutton showName="编辑" shiro="hotel:roomConfig:edit" iconCls="icon-edit" onclick="editRoomConfig()"/>
						<@eu.linkbutton showName="刷新" shiro="hotel:roomConfig:refresh" iconCls="icon-reload" onclick="reloadRoomConfig()"/>
						
					</div>
				</div>
			</div>
			<div data-options="region:'center',title: '已配置的设备',border:false,split: true">
				<@eu.datagrid id="deviceLink_selectlist"  idField="id" 
					 url="roomConfig.do?loadRoomConfigSelectDeviceLinks" rownumbers="true" pagination="false"
					 item="com.xdtech.hotel.vo.DeviceLinkItem"/>
			</div>
		</div>
	</div>
	<div data-options="region:'center',title: '客房设备元件维护',border:false,href:'deviceLink.do?deviceLink'">
		
		
	</div>
</div>